﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProxyPattern.DemoTwo
{
    public class GamePlayer : IGamePlayer
    {
        private string name = string.Empty;

        /// <summary>
        /// 構造函數限制誰能創建對象，并同時傳遞姓名
        /// </summary>
        /// <param name="_gamePlayer"></param>
        /// <param name="_name"></param>
        public GamePlayer(IGamePlayer _gamePlayer, string _name)
        {
            if (_gamePlayer == null)
            {
                throw new Exception("不能創建真實角色!");
            }
            else
            {
                this.name = _name;
            }
        }

        public string killBoss()
        {
            return this.name + " 在打怪!" + Environment.NewLine;
        }

        public string login(string user, string password)
        {
            return "登錄名為：" + user + " 的用戶 " + this.name + " 登錄成功!" + Environment.NewLine;
        }

        public string upgrade()
        {
            return this.name + " 又升了一級!" + Environment.NewLine;
        }
    }

}
